#include <bits/stdc++.h>
using namespace std;
#define int long long

int n, p[20004], m1, m2, x;
vector<pair<int, int>> vs;

void opt1(int i, int x) {
	++m1;
	assert(x >= 2);
	vs.push_back({1, i});
	x -= 1;
	while (x--) {
		assert(i + 1 <= n);
		swap(p[i], p[i + 1]); ++i;
	}
}

void opt2(int i) {
	++m2;
	assert(i + 1 <= n);
	vs.push_back({2, i});
	swap(p[i], p[i + 1]);
}

namespace CR200J {
	int get_x(int n) {
		if (n <= 2500) return 2;
		if (n <= 7000) return 8;
		if (n <= 10000) return 16;
		if (n <= 17000) return 56;
		if (n <= 19000) return 90;
		assert(0);
		return -1;
	}
	vector<pair<int, int>> fins;
	int finans = 1ll << 60;
	vector<pair<int, int>> nowans;
	map<vector<int>, int> vis;
	void find_mn(vector<int> fx, int dep) {
		int ans = 0;
		for (int i = 0; i < fx.size(); ++i) {
			for (int j = i + 1; j < fx.size(); ++j) {
				ans += (fx[i] > fx[j]);
			}

		}
		bool flg = 0;
		if (ans < finans) {
			fins = nowans;
			finans = ans;
		} 
		if (dep == 0) return;
		for (int sel = 0; sel + x <= fx.size(); ++sel) {
			nowans.push_back({1, sel + 1});
			vector<int> nx = fx;
			for (int t = 1; t < x; ++t) {
				swap(nx[sel + t - 1], nx[sel + t]);
			}
			find_mn(nx, dep - 1);
			nowans.pop_back();
		}
	}
	void solve1(int n) {
		for (int i = 1; i <= n; ++i) {
			for (int j = 1; j < n; ++j) {
				if (p[j] > p[j + 1]) {
					opt2(j);
				}
			}
		}
	}
	void solve2() {
		int delt = 2; // 增加辅助位
		vector<int> f1;
		for (int i = 1; i <= x + delt; ++i) f1.push_back(p[i]);
		find_mn(f1, 9);
		for (auto i : fins) opt1(i.second, x);
		solve1(x + delt);
//		exit(0);
	}
	void main() {
		x = get_x(n);
		for (int val = n; val >= x; --val) {
			// 思考方向：从大往小，起左去右
			int pos = val;
			while (p[pos] != val && pos >= 1) --pos;
			assert(p[pos] == val);
			// move pos to val
			while (val - pos + 1 >= x) {
				opt1(pos, x);
				pos += x - 1;
				assert(p[pos] == val);
			}
			assert(pos >= val - x + 1);
			while (p[val] != val) opt1(val - x + 1, x);
		}
		solve2();
		for (int i = 1; i <= n; ++i) {
			assert(p[i] == i);
		}
		cout << x << " " << vs.size() << "\n";
		for (auto i : vs) {
			cout << i.first << " " << i.second << "\n";
		}
		if (m1 + m2 > 1.9e6) {
			cerr << "failed\n";
		}
		cerr << m1 << " " << m2 << "\n";
	}
}

signed main() {
	freopen("rotate.in", "r", stdin); freopen("rotate.out", "w", stdout);
	ios::sync_with_stdio(0); cin.tie(0);
	cin >> n; 
	for (int i = 1; i <= n; ++i) {
		cin >> p[i];
	}
	CR200J::main();
	return 0;
}
